<?php
class ParameterSubMenu extends CWidget {
	public $items = array ();

	public $model = null;

	public function run() {
		$av_items = array (
			'list' => CHtml::link(Yii::t('submenu', 'Users list'), array (
				'list'
			)),
			'create' => CHtml::link(Yii::t('submenu', 'New user'), array (
				'create'
			))
		);

		if ($this->model != null && !$this->model->read_only) {
			$av_items['update'] = CHtml::link(Yii::t('submenu', 'Update user'), array (
				'update',
				'mnemonic' => $this->model->param_mnemonic
			));

			$av_items['delete'] = CHtml::linkButton(Yii::t('submenu', 'Delete parameter'), array (
				'submit' => array (
					'delete',
					'mnemonic' => $this->model->param_mnemonic
				),
				'confirm' => Yii::t('submenu', 'Are you sure?')
			));
		}

		$items = array ();
		$controller = $this->controller;
		$action = $controller->action;
		foreach ($this->items as $item) {
			if (array_key_exists($item, $av_items)) {
				$items[] = $av_items[$item];
			}
		}
		$this->render('subMenu', array (
			'items' => $items
		));
	}
}
?>
